﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.Implements;
using Cofe.Core.Interfaces;
using Cofe.Core.Logger;
using Cofe.Core.Service;

namespace Cofe.Core.Property
{
    public class EntryTypeDirectoryLister : IDirectoryLister
    {
        

        #region Constructor
        public EntryTypeDirectoryLister()
        {
            ManualEventSource = new DummyCofeSystemEventSource();
        }

        #endregion

        #region Methods

        public async Task<IPropertyProvider> TryParsePathAsync(string path, EntryConstructionFlags flags)
        {
            IPropertyProvider parsedEntryCore = null;
            if (String.IsNullOrEmpty(path))
                parsedEntryCore = CofeServices.EntryTypeInfoManager
                        .GetRootPropertyProvider(EntryTypes.VolumeKey);
            else
                //if (CofeServices.EntryTypeInfoManager.KnownEntryTypeKey.Contains(path))
                    parsedEntryCore =
                        await CofeServices.EntryTypeInfoManager
                        .GetEntryTypeInfoPPAsync(EntryTypes.VolumeKey, path);// new EntryTypePropertyProvider(path);

            return parsedEntryCore;
        }


        public IEnumerable<IPropertyProvider> GetRootPropertyProviders()
        {
            yield return CofeServices.EntryTypeInfoManager
                        .GetRootPropertyProvider(EntryTypes.VolumeKey);
        }

        #endregion

        #region Data

        private IVolume _volume;

        #endregion

        #region Public Properties

        public IManualCofeSystemEventSource ManualEventSource { get; set; }


        public IVolume Volume
        {
            get { return _volume; }
            set { _volume = value; }
        }

        #endregion


    }
}
